home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9744 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: newsfeed.internetmci.com!panix!not-for-mail
  2. From: acinader@panix.com (Arthur Cinader Jr)
  3. Newsgroups: gnu.g++.help,comp.lang.c++
  4. Subject: IS THIS LEGAL? Static method returns pointer to class
  5. Date: 4 Mar 1996 00:14:08 -0500
  6. Organization: Panix
  7. Message-ID: <4hdu70$efa@panix.com>
  8. NNTP-Posting-Host: panix.com
  9.  
  10. I may be going at this wrong, but I want to have a class
  11. Triangle contain a static method called makeinstance.  The
  12. method will be passed a refernce to a Param object that has
  13. a list of parameters for checking first and then passing to 
  14. the Triangle constructor.
  15.  
  16. The parameters are checked and if all is ok, a Triangle
  17. instance is "newed" and the pointer to the new Trinagle is
  18. returned.  When I compile, I get the following error:
  19.  
  20. % g++ -c triangle.C
  21. In file included from triangle.C:8:
  22. triangle.h:17: syntax error before `*'
  23. ...
  24. %
  25.  
  26. ***The declaration for the class:
  27.  
  28.       1 // triangle.h
  29.       2 // declaration of class Triangle extends shape
  30.       3
  31.       4 #ifndef TRIANGLE_H
  32.       5 #define TRIANGLE_H
  33.       6
  34.       7 #include "point.h"
  35.       8 #include "param.h"
  36.       9
  37.      10 class Trianlge : public Point {
  38.      11 public:
  39.      12     Trinagle(float = 0.0, float = 0.0, float = 0.0);
  40.      13     float gets() const;
  41.      14     virtual void draw() const;
  42.      15
  43.      16     static Param &getParams();
  44.      17     static Triangle *makeinstance(Param &);
  45.      18 private:
  46.      19     float side;
  47.      20 };
  48.      21
  49.      22 #endif
  50.